package org.simpleframework.util;

import java.util.Collection;
import java.util.Map;

/**
 * @author
 * @date 2022/10/4 10:30
 **/
public class ValidationUtil {


    /**
     * 判断String 是否为null 或者 为""
     *
     * @param obj
     * @return
     */
    public static boolean isEmpty(String obj) {
        return (obj == null || "".equals(obj));
    }


    /**
     * @param obj
     * @return
     */
    public static boolean isEmpty(Object[] obj) {
        return obj.length == 0 || obj == null;
    }

    /**
     * 集合健壮性判断
     *
     * @param collection
     * @return
     */
    public static boolean isEmpty(Collection<?> collection) {
        return collection.size() == 0 || collection == null;
    }

    /**
     * @param obj
     * @return
     */
    public static boolean isEmpty(Map<?, ?> obj) {
        return obj == null || obj.isEmpty();
    }

    public static void main(String[] args) {
//        boolean empty = org.simpleframework.util.ValidationUtil.isEmpty("");
//        String str = "        ";
//        System.out.println("empty = " + empty);
//        str = str.trim();
//        boolean empty1 = org.simpleframework.util.ValidationUtil.isEmpty(str);
//        System.out.println("empty1 = " + empty1);
    }
}
